package com.example.printservice.Config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo()) // 一些描述
                .groupName("yangsf")    // 组名
                .enable(true)   // true表示启用swagger，开发完成后可以改为false禁用swagger，这个值用配置文件做更好
                .select()//接口扫描配置
                .apis(RequestHandlerSelectors.basePackage("com.example.printservice.controller")) // 扫描接口
                .build();
    }

    @Bean
    public ApiInfo apiInfo() {
        return new ApiInfo("智慧工作室API文档",
                "智慧工作室后端API",
                "1.0",
                "https://test.yangsf.vip/",
                new Contact("yangsf", "https://test.yangsf.vip/", "877602782@qq.com"),
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }
}


